from appium import webdriver 
from time import sleep

desired_capabilities = {
  "platformName": "Android",
  "platformVersion": "5.1.1",
  "appPackage": "com.baidu.wenku",
  "appActivity": "com.baidu.wenku.splash.view.activity.WelcomeActivity",
  "deviceName": "62001"
}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_capabilities=desired_capabilities)

driver.implicitly_wait(30)
# 点击 同意并继续
driver.find_element_by_id('com.baidu.wenku:id/tv_agree').click()
sleep(20)
# 点击关闭 升级
driver.find_element_by_id('com.baidu.wenku:id/dialog_pic_close').click()
sleep(20)
# 点击 搜索框
driver.find_element_by_id('com.baidu.wenku:id/h5_search_edit_text').click()
sleep(5)
# 输入搜索关键字
driver.find_element_by_id('com.baidu.wenku:id/h5_search_edit_text_inside').send_keys('软件测试面试')
sleep(3)
# 点击 搜索
driver.find_element_by_id('com.baidu.wenku:id/h5_search_operate_text').click()
sleep(30)
# 点击 阮籍测试经典面试题(完整版)
driver.find_element_by_xpath('//*[@text="软件测试经典面试题(完整版)"]').click()
